home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / etc / init.d / console-screen.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2006-11-10  |  6.2 KB  |  245 lines

  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          console-screen
  4. # Required-Start:    $local_fs $remote_fs
  5. # Required-Stop:     $local_fs $remote_fs
  6. # Default-Start:     S 2 3 4 5
  7. # Default-Stop:      0 1 6
  8. # Should-Start:      $syslog
  9. # Should-Stop:    
  10. # Description: Set console screen modes and fonts
  11. # Short-Description:    Prepare console
  12. ### END INIT INFO
  13.  
  14. #
  15. # This is the boot script for the `console-tools' package.
  16. #
  17. # It loads parameters from /etc/console-tools/config, maybe loads
  18. # default screen-font, screen font-map, and application charset-map,
  19. # and maybe start "vcstime"
  20. #
  21. # (c) 1997 Yann Dirson
  22.  
  23. # If setupcon is present, then we've been superseded by console-setup.
  24. if type setupcon >/dev/null 2>&1; then
  25.     exit 0
  26. fi
  27.  
  28. # check if usplash is runing and skip this, we'll get run again later
  29. if pidof usplash > /dev/null; then
  30.     exit 0
  31. fi
  32.  
  33. if [ -r /etc/console-tools/config ] ; then
  34.     . /etc/console-tools/config
  35. fi
  36.  
  37. if [ -d /etc/console-tools/config.d ]; then
  38.     for i in `run-parts --list /etc/console-tools/config.d `; do
  39.        . $i
  40.     done
  41. fi
  42.  
  43. . /lib/lsb/init-functions
  44.  
  45. PATH=/sbin:/bin:/usr/sbin:/usr/bin
  46. SETFONT="/usr/bin/consolechars"
  47. SETFONT_OPT=""
  48. CHARSET="/usr/bin/charset"
  49. VCSTIME="/usr/sbin/vcstime"
  50.  
  51. # Different device name for 2.6 kernels and devfs
  52. if [ `uname -r | cut -f 2 -d .` = 6 ] && [ -e /dev/.devfsd ]; then
  53.     VCSTIME_OPT="-2 /dev/vcsa0"
  54. else
  55.     VCSTIME_OPT=""
  56. fi
  57.  
  58.  
  59.  
  60. # set DEVICE_PREFIX depending on devfs/udev
  61. if [ -d /dev/vc ]; then
  62.     DEVICE_PREFIX="/dev/vc/"
  63. else
  64.     DEVICE_PREFIX="/dev/tty"
  65. fi
  66.  
  67. reset_vga_palette ()
  68. {
  69.     if [ -f /proc/fb ]; then
  70.            # They have a framebuffer device.
  71.            # That means we have work to do...
  72.         echo -n "]R"
  73.     fi
  74. }
  75.  
  76. setup ()
  77. {
  78.     # be sure the main program is installed
  79.     [ -x "${SETFONT}" ] || return 0
  80.  
  81.     VT="no"
  82.     # If we can't access the console, quit
  83.     CONSOLE_TYPE=`fgconsole 2>/dev/null` || return 0
  84.  
  85.     if [ ! $CONSOLE_TYPE = "serial" ]  ; then
  86.     readlink /proc/self/fd/0 | grep -q -e /dev/vc -e '/dev/tty[^p]' -e /dev/console
  87.     if [ $? -eq 0 ] ; then
  88.         VT="yes"
  89.         reset_vga_palette
  90.     fi
  91.     fi
  92.  
  93.     [ $VT = "no" ] && return 0
  94.  
  95.     # start vcstime
  96.     if [ "${DO_VCSTIME}" = "yes" -a -x ${VCSTIME} ] ; then
  97.     [ "$VERBOSE" != "no" ] && log_action_begin_msg "Starting clock on text console"
  98.     ${VCSTIME} ${VCSTIME_OPT} &
  99.         [ "$VERBOSE" != "no" ] && log_action_end_msg 0
  100.     fi
  101.  
  102.  
  103.     # Global default font+sfm
  104.     if [ "${SCREEN_FONT}" ]
  105.     then
  106.     [ "$VERBOSE" != "no" ] && log_action_begin_msg "Setting up general console font"
  107.     SCREEN_FONT="-f ${SCREEN_FONT}"
  108.  
  109.     # maybe use an external SFM
  110.     [ "${SCREEN_FONT_MAP}" ] && SCREEN_FONT_MAP="-u ${SCREEN_FONT_MAP}"
  111.  
  112.     # Try to be cleverer and run for all consoles, but this is run
  113.     # _before_ getty and so only one console running. So,
  114.     # Set for the first 6 VCs (as they are allocated in /etc/inittab)
  115.     NUM_CONSOLES=`fgconsole --next-available`
  116.     NUM_CONSOLES=$(($NUM_CONSOLES - 1))
  117.     [ ${NUM_CONSOLES} -eq 1 ] && NUM_CONSOLES=6
  118.     i=1
  119.     while [ $i -lt $NUM_CONSOLES ]
  120.         do
  121.         if ! ${SETFONT} --tty=${DEVICE_PREFIX}$i ${SETFONT_OPT} ${SCREEN_FONT} ${SCREEN_FONT_MAP} ; then
  122.           [ "$VERBOSE" != "no" ] && log_action_end_msg 1
  123.           break
  124.         elif [ "$i" -eq "$NUM_CONSOLES" ]; then
  125.           [ "$VERBOSE" != "no" ] && log_action_end_msg 0
  126.         fi
  127.         i=$(($i + 1))
  128.     done
  129.     fi
  130.  
  131.  
  132.     # Per-VC font+sfm
  133.     VCS="`set | grep '^SCREEN_FONT_vc[0-9]*=' | sed -e 's/^SCREEN_FONT_vc//' -e 's/=.*//'`"
  134.     if [ "${VCS}" ]
  135.     then
  136.     [ "$VERBOSE" != "no" ] && log_action_begin_msg "Setting up per-VC fonts"
  137.     for vc in ${VCS}
  138.       do
  139.         # extract FONTNAME info from variable setting
  140.       eval font=\$SCREEN_FONT_vc$vc
  141.       # eventually find an associated SFM
  142.       eval sfm=\${SCREEN_FONT_MAP_vc${vc}}
  143.       [ "$sfm" ] && sfm="-u $sfm"
  144.  
  145.       ${SETFONT} --tty=${DEVICE_PREFIX}$vc ${SETFONT_OPT} -f $font $sfm
  146.     done
  147.     [ "$VERBOSE" != "no" ] && log_action_end_msg 0
  148.     fi
  149.  
  150.  
  151.     # Global ACM
  152.     [ "${APP_CHARSET_MAP}" ] && ${CHARSET} G0 ${APP_CHARSET_MAP}
  153.  
  154.  
  155.     # Per-VC ACMs
  156.     VCS="`set | grep '^APP_CHARSET_MAP_vc[0-9]*=' | sed -e 's/^APP_CHARSET_MAP_vc//' -e 's/=.*//'`"
  157.     if [ "${VCS}" ]
  158.     then
  159.     [ "$VERBOSE" != "no" ] && log_action_begin_msg "Setting up per-VC ACM\'s"
  160.     for vc in ${VCS}
  161.       do
  162.         # extract FONTNAME info from variable setting
  163.       eval acm=\$APP_CHARSET_MAP_vc$vc
  164.       ${CHARSET} --tty="${DEVICE_PREFIX}$vc" G0 "$acm"
  165.     done
  166.     [ "$VERBOSE" != "no" ] && log_action_end_msg 0
  167.     fi
  168.  
  169.  
  170.     # Go to UTF-8 mode as necessary
  171.     # 
  172.     ENV_FILE=''
  173.     [ -r /etc/environment ] && ENV_FILE="/etc/environment"
  174.     [ -r /etc/default/locale ] && ENV_FILE="/etc/default/locale"
  175.     [ "$ENV_FILE" ] && CHARMAP=$(set -a && . "$ENV_FILE" && locale charmap)
  176.     if test "$CHARMAP" = "UTF-8" 
  177.     then
  178.         unicode_start 2> /dev/null || true
  179.     else
  180.         unicode_stop 2> /dev/null|| true
  181.     fi
  182.  
  183.     # screensaver stuff
  184.     setterm_args=""
  185.     if [ "$BLANK_TIME" ]; then
  186.         setterm_args="$setterm_args -blank $BLANK_TIME"
  187.     fi
  188.     if [ "$BLANK_DPMS" ]; then
  189.         setterm_args="$setterm_args -powersave $BLANK_DPMS"
  190.     fi
  191.     if [ "$POWERDOWN_TIME" ]; then
  192.         setterm_args="$setterm_args -powerdown $POWERDOWN_TIME"
  193.     fi
  194.     if [ "$setterm_args" ]; then
  195.         setterm $setterm_args 
  196.     fi
  197.  
  198.     # Keyboard rate and delay
  199.     KBDRATE_ARGS=""
  200.     if [ -n "$KEYBOARD_RATE" ]; then
  201.         KBDRATE_ARGS="-r $KEYBOARD_RATE"
  202.     fi
  203.     if [ -n "$KEYBOARD_DELAY" ]; then
  204.         KBDRATE_ARGS="$KBDRATE_ARGS -d $KEYBOARD_DELAY"
  205.     fi
  206.     if [ -n "$KBDRATE_ARGS" ]; then
  207.     [ "$VERBOSE" != "no" ] && log_action_begin_msg "Setting keyboard rate and delay"
  208.         kbdrate -s $KBDRATE_ARGS
  209.     [ "$VERBOSE" != "no" ] && log_action_end_msg 0
  210.     fi
  211.  
  212.     # Inform gpm if present, of potential changes.
  213.     if [ -f /var/run/gpm.pid ]; then
  214.     kill -WINCH `cat /var/run/gpm.pid` 2> /dev/null
  215.     fi
  216.  
  217.     # Allow user to remap keys on the console
  218.     if [ -r /etc/console-tools/remap ]
  219.     then
  220.     dumpkeys < ${DEVICE_PREFIX}1 | sed -f /etc/console-tools/remap | loadkeys --quiet
  221.     fi
  222.     # Set LEDS here
  223.     if [ "$LEDS" != "" ]
  224.     then
  225.     i=1
  226.     while [ $i -lt $NUM_CONSOLES ]
  227.       do
  228.           setleds -D $LEDS < $DEVICE_PREFIX$i
  229.       i=$(($i + 1))
  230.     done
  231.     fi
  232. }
  233.  
  234. case "$1" in
  235.     start|reload|restart|force-reload)
  236.     log_action_msg "Setting console screen modes and fonts"
  237.     setup
  238.     ;;
  239.     stop)
  240.     ;;
  241.     *)
  242.     setup
  243.     ;;
  244. esac
  245.